package com.langshixiaobai.admin.common.utils;


import com.langshixiaobai.admin.common.filter.UserTransmitFilter;
import lombok.experimental.Accessors;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * 用户配置自动装配
 */
@Configuration
//@Accessors(chain = true)
public class UserConfiguration  {

    /**
     * 用户信息传递过滤器
     */
    // 如果有多个，需要创建多个
    @Bean
    public FilterRegistrationBean<UserTransmitFilter> globalUserTransmitFilter(){
        FilterRegistrationBean<UserTransmitFilter> filters = new FilterRegistrationBean<>();
        filters.addUrlPatterns("/*");
        filters.setFilter(new UserTransmitFilter());
        filters.setOrder(0);
        return filters;
    }
}
